package com.education.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 家教分类表
 *
 * @author education-platform
 * @since 2024-09-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("category")
@JsonIgnoreProperties(value = {"handler"})
public class Category {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 分类名称
     */
    @TableField("name")
    private String name;

    /**
     * 父分类ID，0表示顶级分类
     */
    @TableField("parent_id")
    private Long parentId;

    /**
     * 排序值，越小越靠前
     */
    @TableField("sort")
    private Integer sort;

    /**
     * 状态
     */
    @TableField("status")
    private String status;

    /**
     * 分类图标
     */
    @TableField("icon")
    private String icon;

    /**
     * 分类描述
     */
    @TableField("description")
    private String description;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    // 关联对象（用于XML映射）
    @TableField(exist = false)
    private List<Category> children;

    // 枚举定义
    public enum Status {
        ACTIVE("启用"),
        INACTIVE("停用");

        private final String description;

        Status(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
}

